<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2022-11-18 21:46:49
 * @Last Modified time: 2022-11-28 18:16:31
 */

namespace app\common\model\mate;

use frank\base\BaseModel;
use frank\traits\ModelTrait;
use think\facade\Request;

/**
 * 文件
 * Class FilesModel
 * @package app\common\model\mate
 */
class FilesModel extends BaseModel
{
    use ModelTrait;

    /**
     * 数据表主键
     */
    protected $pk = 'id';

    /**
     * 模型名称
     */
    protected $name = 'mate_files';

    protected $append = [
        'file_url'
    ];
    
    public function getFileUrlAttr($value,$data){
        $domain = ($data['oss_type'] == 'local'?Request::instance()->domain():$data['file_domain']);
        return $domain.'/'.$data['file_path'];
    }
}